package com.bwie.gddproject.login.model;

import com.bwie.gddproject.net.NetUtil;
import com.bwie.gddproject.net.OnNetLitenner;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by 我走路带风 on 2017/11/8.
 */

public class LoginModel implements ILoginModel {

    @Override
    public void login(String account, String pwd, final OnNetLitenner<LoginBean> onNetListener) {

        NetUtil.getResponseService().loginIn(account, pwd)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<LoginBean>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(LoginBean loginBean) {
                        onNetListener.success(loginBean);
                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
